package test;

import java.util.Arrays;
import java.util.List;

public class GenericTest2 {
	public static <T extends Comparable<? super T>> T max(List<? extends T> list) {
		return null;//具体的实现省略.....
	}

	public static void main(String[] args) {
		max(Arrays.asList(new MyNumber()));//不使用?extends和super的最一般情况
		max(Arrays.asList(new MyInteger()));//如果不是Comparable<? super T>而是Comparable<T>的话就会报错,因为MyInteger extends的是Comparable<MyNumber>而不是Comparable<MyInteger>
		GenericTest2.<MyInteger> max(Arrays.asList(new MyPositiveInteger()));//如果不是List<? extends T>而是List<T>的话就会报错,因为T在这里是MyInteger
	}
}

class MyNumber implements Comparable<MyNumber> {
	@Override
	public int compareTo(MyNumber o) {
		return 0;//具体实现省略....
	}

}

class MyInteger extends MyNumber {

}

class MyPositiveInteger extends MyInteger {

}